import type { Router } from 'vue-router';
import 'nprogress/nprogress.css';
import NProgress from 'nprogress';

NProgress.configure({showSpinner: false}); // 进度环显示隐藏

// 进度条
export function createNProgressGuard(router: Router) {
  router.beforeEach(async (to, from) => {
    NProgress.start();
  });
  router.afterEach((to) => {
    NProgress.done();
    // 移除全局加载动画
    document.getElementById('first-loading-wrap')?.remove();
  });
}
